package com.lxp.project.function.controller;

import java.util.Arrays;

import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxp.framework.aspectj.lang.annotation.Log;
import com.lxp.framework.aspectj.lang.enums.BusinessType;
import com.lxp.project.function.domain.FnOrder;
import com.lxp.project.function.service.IFnOrderService;
import com.lxp.framework.web.controller.BaseController;
import com.lxp.framework.web.domain.AjaxResult;
import com.lxp.framework.web.page.TableDataInfo;

/**
 * 预约管理Controller
 *
 * @author 乐乐
 * @date 2022-05-04
 */
@RestController
@RequestMapping("/function/order")
public class FnOrderController extends BaseController {
    @Resource
    private IFnOrderService fnOrderService;

    /**
     * 查询预约管理列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FnOrder fnOrder, TableDataInfo tableSupport) {
        return fnOrderService.getPageList(fnOrder,tableSupport);
    }

    /**
     * 查询所有预约管理列表
     */
    @GetMapping("/listAll")
    public AjaxResult getAllList() {
        return AjaxResult.success(fnOrderService.getAllList());
    }

    /**
     * 导出预约管理列表
     */
    @PreAuthorize("@ss.hasPermi('function:order:export')")
    @Log(title = "预约管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FnOrder fnOrder) {
        return fnOrderService.exports(fnOrder);
    }

    /**
     * 获取预约管理详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(fnOrderService.getById(id));
    }

    /**
     * 新增预约管理
     */
    @Log(title = "预约管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FnOrder fnOrder) {
        return fnOrderService.saveData(fnOrder);
    }

    /**
     * 修改预约管理
     */
    @PreAuthorize("@ss.hasPermi('function:order:edit')")
    @Log(title = "预约管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FnOrder fnOrder) {
        return fnOrderService.updateDataById(fnOrder);
    }

    /**
     * 删除预约管理
     */
    @Log(title = "预约管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return fnOrderService.removeByIds(Arrays.asList(ids));
    }
}
